#include <myhead.h>
pthread_mutex_t st;
int i=0;
void*task(void *arg)
{
	while(1)
	{
		if(i==1)
		{
			pthread_mutex_lock(&st);
			usleep(50000);
			printf("B\n");
			i=0;
			pthread_mutex_unlock(&st);
		}
	}
	return NULL;
}
int main(int argc, const char *argv[])
{
	pthread_t p;
	pthread_create(&p,NULL,task,NULL);
	pthread_mutex_init(&st,NULL);
	while(1)
	{
		if(i==0)
		{
			pthread_mutex_lock(&st);
			usleep(50000);
			printf("A\n");
			i=1;
			pthread_mutex_unlock(&st);
		}
	}
	pthread_mutex_destroy(&st);
	pthread_join(p,NULL);
	return 0;
}
